package be.nvlooy.moviereminder.entities;

import javax.persistence.*;
import java.util.Date;

/**
 * @author: Nik Van Looy
 * @since: 9/10/11
 */
@MappedSuperclass
public abstract class BaseEntity {

    @Column(name="date_created", nullable=false)
	@Temporal(TemporalType.TIMESTAMP)
	private Date dateCreated;

    @Column(name="date_updated", nullable=true)
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateUpdated;


    @PrePersist
    protected void onCreate() {
        dateCreated = new Date();
    }

    @PreUpdate
    protected void onUpdate() {
        dateUpdated = new Date();
    }

    public Date getDateCreated() {
        return dateCreated;
    }

    public void setDateCreated(Date dateCreated) {
        this.dateCreated = dateCreated;
    }

    public Date getDateUpdated() {
        return dateUpdated;
    }

    public void setDateUpdated(Date dateUpdated) {
        this.dateUpdated = dateUpdated;
    }
}
